def compare(int1,int2):
    return 1 if str(int1)+str(int2)<=str(int2)+str(int1) else 0 

def solve(nums):
    n=len(nums)
    for i in range(n):
        for j in range(i+1,n):
            if compare(nums[i],nums[j])==0: nums[i],nums[j]=nums[j],nums[i]
    return int(''.join([str(i) for i in nums]))


print(solve([3,32,321]))
